Fix the output type of `staticlib`
authorAlex Crichton <alex@alexcrichton.com>
Mon, 4 Aug 2014 14:00:17 +0000 (07:00 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 6 Aug 2014 18:28:25 +0000 (11:28 -0700)
The file-naming bits weren't handling the staticlib case

src/cargo/core/manifest.rs
src/cargo/ops/cargo_rustc/context.rs
tests/support/paths.rs
tests/test_cargo_compile.rs

index 3751f6958aabfde6705746c58c3dce9170047087..e4249ca9c6d0f6ee83b645278c5d946fec20a80c 100644 (file)
@@ -416,6 +416,13 @@ impl Target {
         }
     }
 
+    pub fn is_staticlib(&self) -> bool {
+        match self.kind {
+            LibTarget(ref kinds) => kinds.iter().any(|&k| k == StaticLib),
+            _ => false
+        }
+    }
+
     pub fn is_bin(&self) -> bool {
         match self.kind {
             BinTarget => true,
index 4529c823f34f7ccddb3b828d123cd094bf04643e..4f86a70b5e83580a5bde58564273f9da7a79f590 100644 (file)
@@ -191,6 +191,9 @@ impl<'a, 'b> Context<'a, 'b> {
             if target.is_rlib() {
                 ret.push(format!("lib{}.rlib", stem));
             }
+            if target.is_staticlib() {
+                ret.push(format!("lib{}.a", stem));
+            }
         }
         assert!(ret.len() > 0);
         return ret;
index f53cc02d00b0d560dca779fd96d61923cd947d28..51180e38d7c3befaa2390a3d4ed8ce53dc24de99 100644 (file)
@@ -76,11 +76,6 @@ impl PathExt for Path {
 
             let hour = 1000 * 3600;
             let mut newtime = stat.modified - hour;
-            // FIXME: this looks like a bug on windows that needs to be fixed
-            // upstream
-            if cfg!(windows) {
-                newtime = newtime * 1000;
-            }
             fs::change_file_times(path, newtime, newtime)
         }
     }
index 03c32fd4837491e8b962a119459ecfb590c543e5..78c2ab94da927145699d36cbc6576ba156dba6b5 100644 (file)
@@ -1396,3 +1396,20 @@ test!(lib_with_standard_name {
                        compiling = COMPILING,
                        dir = p.root().display()).as_slice()));
 })
+
+test!(simple_staticlib {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+              [package]
+              name = "foo"
+              authors = []
+              version = "0.0.1"
+
+              [[lib]]
+              name = "foo"
+              crate-type = ["staticlib"]
+        "#)
+        .file("src/lib.rs", "pub fn foo() {}");
+
+    assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
+})